package com.qy139.store.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qy139.entity.Room;
import com.qy139.entity.Seat;
import com.qy139.store.service.ISeatService;
import com.qy139.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hjl
 * @since 2021-12-04
 */
@Api(tags = "自习室座位管理")
@RestController
@RequestMapping("/seat")
public class SeatController {
    @Autowired
    private ISeatService seatService;
    //两表联查
    @ApiOperation(notes = "分页两表联查", value = "查询座位")
    @GetMapping("/findAllSeat")
    public Result findAllSeat(Page<Seat> page,@ApiParam("自习室ID")Integer roomId){
        IPage<Seat> page1 = seatService.findAllSeat(page,roomId);
        return new Result(page1);
    }
    /*修改 逻辑删除*/
    @ApiOperation(notes = "座位逻辑删除", value = "修改座位")
    @PostMapping("/updateSeat")
    public Result updateSeat(@RequestBody Seat seat){
        seat.setUpdatetime(new Date());
        return new Result(seatService.saveOrUpdate(seat));
    }
}

